package day0725API;

import java.io.Serializable;
import java.util.Objects;

//User类实现Serializable接口： 则User类的对象就可以进行序列化和行反序列化
public class User  implements  Serializable{
    private  transient Integer id;//让某个变量不参与序列化
    private  String userName;
    private  Character gender;

    public User() { }

    public User(Integer id, String userName, Character gender) {
        this.id = id;
        this.userName = userName;
        this.gender = gender;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Character getGender() {
        return gender;
    }

    public void setGender(Character gender) {
        this.gender = gender;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return Objects.equals(id, user.id) && Objects.equals(userName, user.userName) && Objects.equals(gender, user.gender);
    }

    public int hashCode() {
        return Objects.hash(id, userName, gender);
    }

    public String toString() {
        return "User{" +
                "id=" + id +
                ", userName='" + userName + '\'' +
                ", gender=" + gender +
                '}';
    }
}
